package com.lvt.design.pattern.create.single.demo04;

import java.util.concurrent.atomic.AtomicLong;

/**
 * desc：class
 * 静态类实现
 *
 * @author LT
 * @date 2022/11/30
 */
public class IdGenerator {

    private AtomicLong id = new AtomicLong(0);

    private IdGenerator() {
    }

    private static class SingleHolder{
        private static final IdGenerator instance = new IdGenerator();
    }

    public static  IdGenerator getInstance() {
        return SingleHolder.instance;
    }

    public Long getId() {
        return id.incrementAndGet();
    }
}
